/**
 * @summary 文章模块
 * @author 陈敬善
 */
import * as articleApi from '@/api/article';

export default {
  namespaced: true,
  state: {
    articleList: [],
    // 文章详情模块
    articleListID: {},
  },

  mutations: {
    SET_ARTICLE_LIST(state, newValue) {
      state.articleList = newValue;
    },
    SET_ARTICLE(state, newValue) {
      state.articleListID = newValue;
    },
  },
  actions: {
    async updateArticleList({ commit }, id) {
      const res = await articleApi.getArticleList(id);
      commit('SET_ARTICLE_LIST', res)
    },
    async updateArticle({ commit }, id) {
      const res = await articleApi.getArticleListId(id);
      commit('SET_ARTICLE', res)
    },
  },
};
